<?php
/**
 * Created by PhpStorm.
 * User: 15814
 * Date: 2018/10/8
 * Time: 14:56
 */

header("Content-Type:application/json;charset=utf-8");
header("Access-Control-Allow-Origin:*");


$pid=isset($_REQUEST["pid"]) ? $_REQUEST["pid"] : "";
if($pid!=""){
    $data= file_get_contents("goods.json");
    $arr=json_decode($data);
    for ($i=0;$i<count($arr);$i++){
        if ($arr[$i]->p_id==$pid){
            print_r(json_encode($arr[$i]));
            return;
        }

    }
    print_r('[]');

}
else{
    $data=file_get_contents("goods.json");
    print_r($data);
}









